
<style>
    .table{
        border: 1px solid #333;
        overflow: hidden;
        /*height: 85vh;*/
    }
    .table > thead > tr > th{
        border: 1px solid #333;
    }
    .table td, .table th{
        border: 1px solid #333;
    }
    #a1-form{
        /*overflow: scroll;*/
    }
    td input{
        width: 100%;
    }
</style>
<div class="panel-body">
    <div id="myTabContent" class="tab-content">
        <!--@formatter:off-->

        <div class="widget-body no-padding">
            <form id="a1-form" class="edit-form form-horizontal" role="form" data-toggle="validator" method="POST" action="#">
                <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-4">
                    <label class="control-label col-xs-2">年份选择</label>
                    <div class="col-xs-10 col-lg-6">
                        <select class="form-control" id="year" name="year">
                            {foreach $year_arr as $index=>$vo}
                            <option value="{$vo}" {if condition="$vo==$year"}selected{/if}>{$vo}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div class="col-xs-3">
                        <input type="button"  id="tj"  class="btn btn-success btn-block" value="提交"/>
                    </div>
                </div>
                <a class="btn btn-info btn-myexcel-export" id="tjs" title="导出" href="javascript:;"><i class="fa fa-download"></i> 导出</a>
                <!--<a class="btn btn-info btn-myexcel-export" title="导出" href="{:url('financing.administrative/export')}"><i class="fa fa-download"></i> 导出</a>-->
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th width="6%">费用项目</th>
                        <th width="6%">项目明细</th>
                        <th width="6%">1月</th>
                        <th width="6%">2月</th>
                        <th width="6%">3月</th>
                        <th width="6%">4月</th>
                        <th width="6%">5月</th>
                        <th width="6%">6月</th>
                        <th width="6%">7月</th>
                        <th width="6%">8月</th>
                        <th width="6%">9月</th>
                        <th width="6%">10月</th>
                        <th width="6%">11月</th>
                        <th width="6%">12月</th>
                        <th width="6%">本年累计</th>
                    </tr>
                    </thead>
                    <tbody>



                    <tr>
                        <td colspan="2"><center>总计</center></td>
                        <td class="rowName1 rowN">{$arrs[0]}</td>
                        <td class="rowName2 rowN">{$arrs[1]}</td>
                        <td class="rowName3 rowN">{$arrs[2]}</td>
                        <td class="rowName4 rowN">{$arrs[3]}</td>
                        <td class="rowName5 rowN">{$arrs[4]}</td>
                        <td class="rowName6 rowN">{$arrs[5]}</td>
                        <td class="rowName7 rowN">{$arrs[6]}</td>
                        <td class="rowName8 rowN">{$arrs[7]}</td>
                        <td class="rowName9 rowN">{$arrs[8]}</td>
                        <td class="rowName10 rowN">{$arrs[9]}</td>
                        <td class="rowName11 rowN">{$arrs[10]}</td>
                        <td class="rowName12 rowN">{$arrs[11]}</td>
                        <td class="rowName13"></td>
                    </tr>

                    <tr>
                        <td rowspan="5" style= "text-align:center; vertical-align: middle;">固定支出</td>
                        <td><center>办公房租</center></td>

                        {foreach $name[1] as $index=>$vo}
                        <td class="row1 name{$index+1}"><input class="form-control" name="1[{$index+1}]" type="text" oninput="inputNum(1,'{$index+1}')" onblur="checkmoney(1,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal1">{$names[1]}</td>
                    </tr>
                    <tr>
                        <td><center>办公水电等管理杂费</center></td>
                        {foreach $name[2] as $index=>$vo}
                        <td class="row2 name{$index+1}"><input class="form-control" name="2[{$index+1}]" type="text" oninput="inputNum(2,'{$index+1}')" onblur="checkmoney(2,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal2">{$names[2]}</td>
                    </tr>

                    <tr>
                        <td><center>员工工资</center></td>
                        {foreach $name[3] as $index=>$vo}
                        <td class="row3 name{$index+1}"><input class="form-control" name="3[{$index+1}]" type="text" oninput="inputNum(3,'{$index+1}')" onblur="checkmoney(3,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal3">{$names[3]}</td>
                    </tr>

                    <tr>
                        <td><center>员工保险费</center></td>
                        {foreach $name[4] as $index=>$vo}
                        <td class="row4 name{$index+1}"><input class="form-control" name="4[{$index+1}]" type="text" oninput="inputNum(4,'{$index+1}')" onblur="checkmoney(4,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal4">{$names[4]}</td>
                    </tr>

                    <tr>
                        <td><center>员工公积金</center></td>
                        {foreach $name[5] as $index=>$vo}
                        <td class="row5 name{$index+1}"><input class="form-control" name="5[{$index+1}]" type="text" oninput="inputNum(5,'{$index+1}')" onblur="checkmoney(5,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal5">{$names[5]}</td>
                    </tr>


                    <tr>
                        <td rowspan="2" style= "text-align:center; vertical-align: middle;">合同支出</td>
                        <td><center>新办公场所装修</center></td>
                        {foreach $name[6] as $index=>$vo}
                        <td class="row6 name{$index+1}"><input class="form-control" name="6[{$index+1}]" type="text" oninput="inputNum(6,'{$index+1}')" onblur="checkmoney(6,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal6">{$names[6]}</td>
                    </tr>
                    <tr>
                        <td><center>品牌设计</center></td>
                        {foreach $name[7] as $index=>$vo}
                        <td class="row7 name{$index+1}"><input class="form-control" name="7[{$index+1}]" type="text" oninput="inputNum(7,'{$index+1}')" onblur="checkmoney(7,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal7">{$names[7]}</td>
                    </tr>


                    <tr>
                        <td rowspan="9" style= "text-align:center; vertical-align: middle;">采购支出</td>
                        <td><center>办公用品</center></td>
                        {foreach $name[8] as $index=>$vo}
                        <td class="row8 name{$index+1}"><input class="form-control" name="8[{$index+1}]" type="text" oninput="inputNum(8,'{$index+1}')" onblur="checkmoney(8,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal8">{$names[8]}</td>
                    </tr>
                    <tr>
                        <td><center>办公电脑</center></td>
                        {foreach $name[9] as $index=>$vo}
                        <td class="row9 name{$index+1}"><input class="form-control" name="9[{$index+1}]" type="text" oninput="inputNum(9,'{$index+1}')" onblur="checkmoney(9,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal9">{$names[9]}</td>
                    </tr>
                    <tr>
                        <td><center>办公费用</center></td>
                        {foreach $name[10] as $index=>$vo}
                        <td class="row10 name{$index+1}"><input class="form-control" name="10[{$index+1}]" type="text" oninput="inputNum(10,'{$index+1}')" onblur="checkmoney(10,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal10">{$names[10]}</td>
                    </tr>
                    <tr>
                        <td><center>网络费</center></td>
                        {foreach $name[11] as $index=>$vo}
                        <td class="row11 name{$index+1}"><input class="form-control" name="11[{$index+1}]" type="text" oninput="inputNum(11,'{$index+1}')" onblur="checkmoney(11,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal11">{$names[11]}</td>
                    </tr>
                    <tr>
                        <td><center>办公室装修物品采购</center></td>
                        {foreach $name[12] as $index=>$vo}
                        <td class="row12 name{$index+1}"><input class="form-control" name="12[{$index+1}]" type="text" oninput="inputNum(12,'{$index+1}')" onblur="checkmoney(12,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal12">{$names[12]}</td>
                    </tr>
                    <tr>
                        <td><center>市场营销等费用</center></td>
                        {foreach $name[13] as $index=>$vo}
                        <td class="row13 name{$index+1}"><input class="form-control" name="13[{$index+1}]" type="text" oninput="inputNum(13,'{$index+1}')" onblur="checkmoney(13,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal13">{$names[13]}</td>
                    </tr>
                    <tr>
                        <td><center>药品</center></td>
                        {foreach $name[14] as $index=>$vo}
                        <td class="row14 name{$index+1}"><input class="form-control" name="14[{$index+1}]" type="text" oninput="inputNum(14,'{$index+1}')" onblur="checkmoney(14,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal14">{$names[14]}</td>
                    </tr>
                    <tr>
                        <td><center>医用耗材</center></td>
                        {foreach $name[15] as $index=>$vo}
                        <td class="row15 name{$index+1}"><input class="form-control" name="15[{$index+1}]" type="text" oninput="inputNum(15,'{$index+1}')" onblur="checkmoney(15,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal15">{$names[15]}</td>
                    </tr>
                    <tr>
                        <td><center>医疗器械</center></td>
                        {foreach $name[16] as $index=>$vo}
                        <td class="row16 name{$index+1}"><input class="form-control" name="16[{$index+1}]" type="text" oninput="inputNum(16,'{$index+1}')" onblur="checkmoney(16,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal16">{$names[16]}</td>
                    </tr>

                    <tr>
                        <td rowspan="14" style= "text-align:center; vertical-align: middle;">其它支出</td>
                        <td><center>办公交通费（市内）</center></td>
                        {foreach $name[17] as $index=>$vo}
                        <td class="row17 name{$index+1}"><input class="form-control" name="17[{$index+1}]" type="text" oninput="inputNum(17,'{$index+1}')" onblur="checkmoney(17,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal17">{$names[17]}</td>
                    </tr>
                    <tr>
                        <td><center>办公差旅费</center></td>
                        {foreach $name[18] as $index=>$vo}
                        <td class="row18 name{$index+1}"><input class="form-control" name="18[{$index+1}]" type="text" oninput="inputNum(18,'{$index+1}')" onblur="checkmoney(18,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal18">{$names[18]}</td>
                    </tr>
                    <tr>
                        <td><center>办公运杂费</center></td>
                        {foreach $name[19] as $index=>$vo}
                        <td class="row19 name{$index+1}"><input class="form-control" name="19[{$index+1}]" type="text" oninput="inputNum(19,'{$index+1}')" onblur="checkmoney(19,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal19">{$names[19]}</td>
                    </tr>
                    <tr>
                        <td><center>办公招待费</center></td>
                        {foreach $name[20] as $index=>$vo}
                        <td class="row20 name{$index+1}"><input class="form-control" name="20[{$index+1}]" type="text" oninput="inputNum(20,'{$index+1}')" onblur="checkmoney(20,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal20">{$names[20]}</td>
                    </tr>
                    <tr>
                        <td><center>教授房租及水电等杂费</center></td>
                        {foreach $name[21] as $index=>$vo}
                        <td class="row21 name{$index+1}"><input class="form-control" name="21[{$index+1}]" type="text" oninput="inputNum(21,'{$index+1}')" onblur="checkmoney(21,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal21">{$names[21]}</td>
                    </tr>
                    <tr>
                        <td><center>员工餐费</center></td>
                        {foreach $name[22] as $index=>$vo}
                        <td class="row22 name{$index+1}"><input class="form-control" name="22[{$index+1}]" type="text" oninput="inputNum(22,'{$index+1}')" onblur="checkmoney(22,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal22">{$names[22]}</td>
                    </tr>
                    <tr>
                        <td><center>过节费</center></td>
                        {foreach $name[23] as $index=>$vo}
                        <td class="row23 name{$index+1}"><input class="form-control" name="23[{$index+1}]" type="text" oninput="inputNum(23,'{$index+1}')" onblur="checkmoney(23,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal23">{$names[23]}</td>
                    </tr>
                    <tr>
                        <td><center>探亲交通费</center></td>
                        {foreach $name[24] as $index=>$vo}
                        <td class="row24 name{$index+1}"><input class="form-control" name="24[{$index+1}]" type="text" oninput="inputNum(24,'{$index+1}')" onblur="checkmoney(24,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal24">{$names[24]}</td>
                    </tr>
                    <tr>
                        <td><center>房补</center></td>
                        {foreach $name[25] as $index=>$vo}
                        <td class="row25 name{$index+1}"><input class="form-control" name="25[{$index+1}]" type="text" oninput="inputNum(25,'{$index+1}')" onblur="checkmoney(25,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal25">{$names[25]}</td>
                    </tr>
                    <tr>
                        <td><center>奖金</center></td>
                        {foreach $name[26] as $index=>$vo}
                        <td class="row26 name{$index+1}"><input class="form-control" name="26[{$index+1}]" type="text" oninput="inputNum(26,'{$index+1}')" onblur="checkmoney(26,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal26">{$names[26]}</td>
                    </tr>
                    <tr>
                        <td><center>全员健康体检</center></td>
                        {foreach $name[27] as $index=>$vo}
                        <td class="row27 name{$index+1}"><input class="form-control" name="27[{$index+1}]" type="text" oninput="inputNum(27,'{$index+1}')" onblur="checkmoney(27,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal27">{$names[27]}</td>
                    </tr>
                    <tr>
                        <td><center>旅游</center></td>
                        {foreach $name[28] as $index=>$vo}
                        <td class="row28 name{$index+1}"><input class="form-control" name="28[{$index+1}]" type="text" oninput="inputNum(28,'{$index+1}')" onblur="checkmoney(28,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal28">{$names[28]}</td>
                    </tr>
                    <tr>
                        <td><center>员工活动/拓展</center></td>
                        {foreach $name[29] as $index=>$vo}
                        <td class="row29 name{$index+1}"><input class="form-control" name="29[{$index+1}]" type="text" oninput="inputNum(29,'{$index+1}')" onblur="checkmoney(29,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal29">{$names[29]}</td>
                    </tr>
                    <tr>
                        <td><center>年会</center></td>
                        {foreach $name[30] as $index=>$vo}
                        <td class="row30 name{$index+1}"><input class="form-control" name="30[{$index+1}]" type="text" oninput="inputNum(30,'{$index+1}')" onblur="checkmoney(30,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal30">{$names[30]}</td>
                    </tr>

                    <tr>
                        <td rowspan="1" style= "text-align:center; vertical-align: middle;">其它</td>
                        <td><center>其它</center></td>
                        {foreach $name[31] as $index=>$vo}
                        <td class="row31 name{$index+1}"><input class="form-control" name="31[{$index+1}]" type="text" oninput="inputNum(31,'{$index+1}')" onblur="checkmoney(31,'{$index+1}')" value="{$vo}"></td>
                        {/foreach}
                        <td class="rowVal31">{$names[31]}</td>
                    </tr>



                    </tbody>
                    <!--<tfoot>-->
                    <!--<tr>-->
                        <!--<td></td>-->
                        <!--<td>-->

                        <!--</td>-->
                        <!--<td></td>-->
                        <!--<td></td>-->
                    <!--</tr>-->
                    <!--</tfoot>-->
                </table>
                <!--<div style="display: flex;justify-content: center">-->
                    <!--<button type="submit" class="btn btn-success btn-embossed">{:__('OK')}</button>-->
                    <!--<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>-->
                <!--</div>-->
            </form>
        </div>
        <!--@formatter:on-->
    </div>
</div>
<script src="/assets/img/jquery-3.4.1.min.js"></script>
<script>

    $('#tj').click(function () {
        var year = $("#year").val();
        //console.log(year);
        //let url = '/BozFPLUfmy.php/statistics/payments/index?ref=addtabs&year='+year;
        let url = '/QjaGeuOTbZ.php/financing/administrative/index?year='+year;
        //window.top.location.href = url;
        location.href=url;
    })

    $('#tjs').click(function () {
        var year = $("#year").val();
        //console.log(year);
        //let url = '/BozFPLUfmy.php/statistics/payments/index?ref=addtabs&year='+year;
        let url = '/QjaGeuOTbZ.php/financing/administrative/export?year='+year;
        //window.top.location.href = url;
        location.href=url;
    })

    var num = 0
    var nums = 0
    function inputNum(row,name){
        //console.log(row);
        num = 0
        nums = 0
        $('.row'+row+' input').each(function(key,value){
            if($(this).val()){
                num = parseFloat($(this).val())+num
                //console.log(num)
                $('.rowVal'+row).html(parseFloat(num))
            }

        });

        $('.name'+name+' input').each(function(key,value){
            //console.log($(this).val())
            if($(this).val()){
                nums = parseFloat($(this).val())+nums
                //console.log(num)
                $('.rowName'+name).html(parseFloat(nums))
            }

        });
    }


    function checkmoney(row,name){
        var year = $("#year").val();
        var arr = row+'['+name+']';
        var money = $("input[name='"+arr+"']").val();

        // console.log(money);
        // console.log(year);
        // console.log(row);
        // console.log(name);

        $.ajax({
            url:"financing/administrative/fors",    //请求的url地址
            dataType:"json",   //返回格式为json
            async:true,//请求是否异步，默认为异步，这也是ajax重要特性
            data:{"money":money,"year":year,"row":row,"name":name,},    //参数值
            type:"POST",   //请求方式
            success:function(data){
                //请求成功时处理
                if (data.code == 0) {
                    Toastr.error(data.msg);
                }else {
                    Toastr.success(data.msg);
                }
            },
        });
    }

    var num_a = 0;
    $('.rowN').each(function(key,value){
        if($(this).html()){
            num_a = parseFloat($(this).html())+num_a;
            //console.log(num)
            $('.rowName13').html(parseFloat(num_a))
        }

    });


</script>
